package com.xie.leetcode.base;

/**
 * @author xiezhendong
 * @date 2022/3/14
 */
public class ListNode {
    public int val;
    public ListNode next;

    public ListNode(int val) {
        this.val = val;
    }

    public ListNode() {
    }

    public ListNode(int val, ListNode next) {
        this.val = val;
        this.next = next;
    }

    @Override
    public String toString() {
        StringBuilder str = new StringBuilder();
        str.append(val);
        if (next != null) {
            str.append("->");
            str.append(next.toString());
        }
        return str.toString();
    }
}
